/**
 * 
 */
package com.geezdata.cps.ttk.query.query.impl;

import java.util.Arrays;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;

import com.geezdata.cps.ttk.domain.domain.TaskItem;
import com.geezdata.cps.ttk.mapper.mapper.TaskItemMapper;
import com.geezdata.cps.ttk.query.query.TaskItemService;
import com.google.common.collect.Maps;

/**
 * @author sszheng
 * @date 创建时间：2018年11月6日 上午11:36:02
 *
 */
@Service
public class TaskItemServiceImpl implements TaskItemService {
	@Autowired
	private TaskItemMapper taskItemMapper;
	
	private static final List<Integer> validStatuses = Arrays.asList(1,2);

	@Override
	public Integer getExistsTaskItemNum(Integer taskId, String openId) {
		Map<String, Object> params = Maps.newHashMap();
		params.put("openId", openId);
		params.put("taskId", taskId);
		params.put("statuses", validStatuses);
		
		List<TaskItem> list = taskItemMapper.selectBatch(params );
		if(CollectionUtils.isEmpty(list)) {
			return 0;
		}
		return list.size();
	}
}
